<%@ page import="com.tang.pojo.Cart" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<html>
<head>
    <title>购物车</title>
    <base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/pages/Cart.jsp"/>
    <style>
        #div0{
            margin:0 auto;
            text-align: center;
        }
        .info{
            color:red;
            font-size:32px;
        }
        #emptyCart{
            color:blue;
            font-size: 32px;
        }
    </style>
    <script type="text/javascript" src="../Jquery/jquery-1.8.3.js"></script>
    <script type="text/javascript" src="CartJS.js"></script>
</head>
<body>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div id="div0">
<table align="center" border="1" cellspacing="0">
    <c:if test="${empty sessionScope.cart.items}">
        <a href="Welcome.jsp"><span id="emptyCart">亲，当前购物车为空呢。快去和小伙伴们一同选购图书吧!</span></a>
    </c:if>
    <c:if test="${not empty sessionScope.cart.items}">
        <tr>
            <th>商品名称</th>
            <th>数量</th>
            <th>单价</th>
            <th>金额</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${sessionScope.cart.items}" var="ct">
            <tr>
                <td>${ct.name}</td>
                <td><input type="text" value="${ct.count}" bookId="${sessionScope.cart.queryId(ct.name)}" class="update"/></td>
                <td>${ct.price}</td>
                <td>${ct.priceTotal}</td>
                <td><a href="../cart?action=deleteBookToCart&id=${sessionScope.cart.queryId(ct.name)}" class="delete">删除</a></td>
            </tr>
        </c:forEach>
    </c:if>
</table><br/><br/><br/>
    <c:if test="${not empty sessionScope.cart.items}">
    购物车共有<span class="info">${sessionScope.cart.countTotal}</span>件商品 总金额<span class="info">${sessionScope.cart.priceTotal}</span>元<br/>
    <a href="../cart?action=clearCart" id="clear">清空购物车</a> <a href="../order?action=generateOrder">去结账</a>
    </c:if>
</div>
<%@include file="../publicPages/footer.jsp" %>
</body>
</html>
